import re
#读取文件
r=open("D:\Walden.txt",'r',encoding='utf-8')
r=r.read()
#全部换成小写
r=r.lower()
#把各种符号转化为空格，不去统计
r=re.sub('[,.?;:"\'!]','',r)
words=r.split()
from collections import Counter
def counter(words):
    return Counter(words).most_common(10)
dict={}
dict=counter(words)
print(dict)
